// pages/bindPhone/bindPhone.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isSend:false,
    cout:60,
    inputValue:''
  },

  
  input:function (e){  
    let that = this
      that.setData({
        inputValue: e.detail.value,
      })
  },

  sendCode: function (){
    let that = this
    let tel = that.data.inputValue
    let warn =""
    let flag = false
    if(tel == ""){
      warn="请填写您的手机号"
    } else if (!(/^1(3|4|5|7|8)\d{9}$/.test(tel))) {
      warn="请输入正确的手机号"
    } else{
      flag = true
      that.setData({
        isSend: true,
        cout: 60
      })
      let isSend = that.data.isSend
      if (isSend == true) {
        that.timeDown();
      }
      
    }
    if (flag == false) {
      wx.showModal({
        title: '提示',
        content: warn
      })
    }
  
  },
 
  timeDown:function(){
      let that = this;
      let cout = 60;
      let time = setInterval(function (){
          cout--;
          that.setData({
            cout:cout
          })
          if(cout <=0){
           clearInterval(time)
           that.setData({
             isSend:false
           })
          }
      },1000)
     
  },
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})